package com.tianyi.sfzy1.service;

import com.tianyi.sfzy1.domain.Course;
import com.tianyi.sfzy1.domain.Coursefavorite;
import com.tianyi.sfzy1.domain.Coursepurchaserecord;
import com.tianyi.sfzy1.mapper.CourseMapper;
import com.tianyi.sfzy1.mapper.CoursepurchaserecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * DYT
 */
@Service
public class CoursePurchaseRecordService {
    @Autowired
    private CoursepurchaserecordMapper coursepurchaserecordMapper;

    //    动态查询所有课程购买记录
    public List<Coursepurchaserecord> findAll(String title,String status,String realname){
        return coursepurchaserecordMapper.findCoursepurchaseAll(title,status,realname);
    }

    //    新增课程购买记录
    public int insert(Coursepurchaserecord coursepurchaserecord){
        return coursepurchaserecordMapper.insert(coursepurchaserecord);
    }

    //    小程序新增课程购买记录
    public int insertOne(int memberId,int courseId,Double purchasePrice){
        return coursepurchaserecordMapper.insertOne(memberId,courseId,purchasePrice);
    }


    //    更改课程购买记录
    public int update(Coursepurchaserecord coursepurchaserecord){
        return coursepurchaserecordMapper.update(coursepurchaserecord);
    }

    //    删除课程购买记录
    public int delete(int id){
        return coursepurchaserecordMapper.delete(id);
    }

    //    批量删除课程购买记录
    public int deleteSelect(List<Integer> list){
        return coursepurchaserecordMapper.deleteSelect(list);
    }

   //小程序根据用户和课程id查询购买记录
   public Coursepurchaserecord find(int memberId,int courseId){
        return coursepurchaserecordMapper.find(memberId,courseId);
   }
}
